package com.company.nuwa.common.utils;

import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * <p></p >
 *
 * @author youyoukele
 * @version 1.0
 * @date 2023/9/8 10:13
 */
@Slf4j
public class MoneyUtils {

    private static final BigDecimal PRICE_RATE = BigDecimal.valueOf(100);

    public static BigDecimal yuanToFen(BigDecimal value) {
        return value == null ? null
                : value.multiply(PRICE_RATE);
    }

    public static BigDecimal fenToYuan(BigDecimal value) {
        return value == null ? null
                : value.divide(PRICE_RATE, 2, RoundingMode.DOWN);
    }

}
